﻿using System;
using GameFramework.skill.effect;
using GameFramework.skill.selector;
using UnityEngine;

namespace GameFramework.skill.deployer
{
    public abstract class SkillDeployer:MonoBehaviour
    {
        protected Skill _skill;
        public Skill Skill //技能管理器提供
        {
            get { return _skill; }
            set { _skill = value; InitDeplopyer(); }
        }
        //敌人选择算法
        private ISkillSelector selector;
        //效果算法对象 
        private ISkillEffect[] effetcArray;
        //初始化释放器
        private void InitDeplopyer()//初始化释放器 
        {
            //范围选择
            selector = DeployerConfigFactory.CreateSkillSelector(_skill);
            //效果
            effetcArray = DeployerConfigFactory.CreateImpactEffects(_skill);
        }
        //范围选择
        public void selectTarges() 
        {
            // _skill.targets = selector.selectTarget(_skill, this.transform);
        }
        //效果
        public void effectTargets() 
        {
            for (int i = 0; i < effetcArray.Length; i++)
            {
                try
                {
                    // effetcArray[i].excute();
                }
                catch (Exception e)
                {
                    Debug.Log(e);
                }

            }
        }
        public abstract void DeploySkill();//供技能管理器调用，由子类实现，定义具体释放策略
    }
}